/**
 * @description 自动import导入所有 api 模块
 */

const files = require.context("./model", false, /\.js$/);
import { visitWeb } from "@/utils/request";
const modulesList = {};
files.keys().forEach((key) => {
	modulesList[key.replace(/(\.\/|\.js)/g, "")] = files(key).default;
});

const modules = new Proxy(modulesList, {
	get(targetmain, propmain) {
		let ress = new Proxy(targetmain, {
			path: targetmain[propmain],
			get(target, prop) {
				let res = ress;
				if (typeof this.path[prop] == "undefined") {
					return null;
				}
				if (typeof this.path[prop].url == "undefined") {

					this.path = this.path[prop];
				} else {
					res = new visitWeb(this.path[prop]);
				}
				return res;
			},
		});
		return ress;
	},
});
export default modules;
